home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbsnip.zip / PLAYCD.BAS < prev    next >
BASIC Source File  |  1997-06-23  |  3KB  |  108 lines

  1. '---------------------------------------------------------------------------
  2. '[PLAYCD.BAS] - v1.00 Public Domain by Denis Boyles. All Rights Reserved.
  3. '---------------------------------------------------------------------------
  4.  
  5. ' This program is more or less identical in function to the CDPLAY program
  6. ' posted by Dave Shea. That is, it will supposedly play an AUDIO CD inserted
  7. ' into the CD-ROM drive of your computer.
  8.  
  9. ' In doing this re-write, I have tried to "clean up" the code; making it
  10. ' easier to read and understand. However, for simplicity, I hard coded the
  11. ' starting sector and total sectors. The original started at sector #1 and
  12. ' played 300,000 sectors. This is what I used as well, but were coded into
  13. ' the SUB rather then being parameters.
  14. '
  15. '        (it eased the clean up, but by all means, change as desired)
  16.  
  17. ' * IMPORTANT *
  18.  
  19. ' This program is UNTESTED since, well, ok, I don't have a CD-ROM drive to
  20. ' test with! (what you say!? :) I have tried to follow the original program,
  21. ' so it should be no worse in functionality in that regard.
  22. '===========================================================================
  23. '
  24. ' Additional notes: Tested by Tika Carr
  25. '
  26. ' This program will NOT work in Windows! You have to run this in DOS only.
  27.  
  28. '$INCLUDE: 'QB.BI'
  29.  
  30. DECLARE SUB CDPlay (drive%)
  31. DECLARE SUB CDStop (drive%)
  32. DECLARE FUNCTION CDGetNumDrives% ()
  33. DECLARE FUNCTION CDGetVersion% ()
  34.  
  35. CONST MULTIPLEX = &H2F                 'DOS INT to access MSCDEX services
  36. CONST CDDRIVE = 4                      '0 = A:, 1 = B:, 2 = C:,...
  37.  
  38. CLS
  39. IF CDGetNumDrives = 0 THEN
  40.     PRINT "ERROR: MSCDEX isn't installed or CD-ROM not hooked up properly!"
  41.     END
  42. END IF
  43.  
  44. CDVer% = CDGetVersion
  45. PRINT USING "MSCDEX v&_.& detected."; HEX$(CDVer% \ 256); HEX$(CDVer% MOD 256)
  46. PRINT : PRINT "Insert AUDIO CD into drive and press [ENTER] to play."
  47. WHILE INKEY$ <> CHR$(13): WEND
  48.  
  49. PRINT : PRINT "Playing..."
  50. CALL CDPlay(CDDRIVE)
  51.  
  52. PRINT : PRINT "Press [ESC] to stop playing."
  53. WHILE INKEY$ <> CHR$(27): WEND
  54.  
  55. PRINT : PRINT "Stopped."
  56. CALL CDStop(CDDRIVE)
  57. END
  58.  
  59. FUNCTION CDGetNumDrives%
  60.     DIM regs AS RegType
  61.  
  62.     regs.ax = &H1500
  63.     regs.bx = 0
  64.     CALL INTERRUPT(MULTIPLEX, regs, regs)
  65.  
  66.     CDGetNumDrives% = regs.bx
  67. END FUNCTION
  68.  
  69. FUNCTION CDGetVersion%
  70.     DIM regs AS RegType
  71.  
  72.     regs.ax = &H150C
  73.     CALL INTERRUPT(MULTIPLEX, regs, regs)
  74.  
  75.     CDGetVersion% = regs.bx
  76. END FUNCTION
  77.  
  78. SUB CDPlay (drive%)
  79.     DIM buffer%(64), regs AS RegTypeX
  80.  
  81.     buffer%(0) = 128
  82.     buffer%(1) = 132
  83.     buffer%(7) = 1                       'StartSec& = 1
  84.     buffer%(8) = 0
  85.     buffer%(9) = -27680                  'NumSec& = 300,000
  86.     buffer%(10) = 4
  87.  
  88.     regs.ax = &H1510
  89.     regs.bx = VARPTR(buffer%(0))
  90.     regs.cx = drive%
  91.     regs.es = VARSEG(buffer%(0))
  92.     CALL INTERRUPTX(MULTIPLEX, regs, regs)
  93. END SUB
  94.  
  95. SUB CDStop (drive%)
  96.     DIM buffer%(64), regs AS RegTypeX
  97.  
  98.     buffer%(0) = 128
  99.     buffer%(1) = 133
  100.  
  101.     regs.ax = &H1510
  102.     regs.bx = VARPTR(buffer%(0))
  103.     regs.cx = drive%
  104.     regs.es = VARSEG(buffer%(0))
  105.     CALL INTERRUPTX(MULTIPLEX, regs, regs)
  106. END SUB
  107.  
  108.